


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
    <title>Routing (Scala) &mdash; Akka Documentation</title>
    
    <link rel="stylesheet" href="../_static/style.css" type="text/css" />
    <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
    <link rel="stylesheet" href="../_static/prettify.css" type="text/css" />
    <link rel="stylesheet" href="../_static/base.css" type="text/css" />
    <link rel="stylesheet" href="../_static/docs.css" type="text/css" />
    <link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Exo:300,400,600,700" type="text/css" />
    
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    '../',
        VERSION:     '2.0.1',
        COLLAPSE_INDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  true
      };
    </script>
    <script type="text/javascript" src="../_static/jquery.js"></script>
    <script type="text/javascript" src="../_static/underscore.js"></script>
    <script type="text/javascript" src="../_static/doctools.js"></script>
    <script type="text/javascript" src="../_static/toc.js"></script>
    <script type="text/javascript" src="../_static/prettify.js"></script>
    <script type="text/javascript" src="../_static/highlightCode.js"></script>
    <script type="text/javascript" src="../_static/effects.core.js"></script>
    <script type="text/javascript" src="../_static/effects.highlight.js"></script>
    <script type="text/javascript" src="../_static/scrollTo.js"></script>
    <script type="text/javascript" src="../_static/contentsFix.js"></script>
    <link rel="shortcut icon" href="../_static/favicon.ico"/>
    <link rel="top" title="Akka Documentation" href="../index.html" />
    <link rel="up" title="Scala API" href="index.html" />
    <link rel="next" title="Remoting (Scala)" href="remoting.html" />
    <link rel="prev" title="Dispatchers (Scala)" href="dispatchers.html" /> 
  </head>
  <body>
  <div class="navbar">
    <div class="navbar-inner">
      <div class="container">
        <div class="navbar-logo">
          <a href="http://akka.io"><img src="../_static/logo-small.png" /></a>
        </div>    
        <ul class="nav">
          <li><a href="http://akka.io/docs">Documentation</a></li>
          <li><a href="http://akka.io/downloads">Download</a></li>
          <li><a href="http://groups.google.com/group/akka-user">Mailing List</a></li>
          <li><a href="http://github.com/akka/akka">Code</a></li>           
          <li><a href="http://typesafe.com/products/typesafe-subscription">Commerical Support</a></li>
        </ul>
      </div>
    </div>
  </div>
  <div class="main">
    <div class="container">
      <div class="page-title">Routing (Scala)</div><div class="pdf-link"><a href="http://akka.io/docs/akka/2.0.1/Akka.pdf"><img src="../_static/pdf-icon.png" style="height: 40px;" /></a></div></div>
    <div class="main-container">
      <div class="container">
        <div class="row">
          <div class="span12">
            <ul class="breadcrumb">           
              <li>
                 <span class="divider">|</span> <a href="remoting.html">Remoting (Scala)</a> <span class="divider">»</span>
              </li>
              <li>
                <a href="../index.html">Contents</a>
              </li>
              <li>
                <span class="divider">«</span> <a href="dispatchers.html">Dispatchers (Scala)</a> <span class="divider">|</span>
              </li>
              <li>
                Version 2.0.1
              </li>
            </ul>         
          </div>
        </div>
        <div class="row">
          <div class="span9">
            
  <div class="section" id="routing-scala">
<span id="id1"></span><h1>Routing (Scala)</h1>
<p>A Router is an actor that routes incoming messages to outbound actors.
The router routes the messages sent to it to its underlying actors called &#8216;routees&#8217;.</p>
<p>Akka comes with some defined routers out of the box, but as you will see in this chapter it
is really easy to create your own. The routers shipped with Akka are:</p>
<ul class="simple">
<li><tt class="docutils literal"><span class="pre">akka.routing.RoundRobinRouter</span></tt></li>
<li><tt class="docutils literal"><span class="pre">akka.routing.RandomRouter</span></tt></li>
<li><tt class="docutils literal"><span class="pre">akka.routing.SmallestMailboxRouter</span></tt></li>
<li><tt class="docutils literal"><span class="pre">akka.routing.BroadcastRouter</span></tt></li>
<li><tt class="docutils literal"><span class="pre">akka.routing.ScatterGatherFirstCompletedRouter</span></tt></li>
</ul>
<div class="section" id="routers-in-action">
<h2>Routers In Action</h2>
<p>This is an example of how to create a router that is defined in configuration:</p>
<div class="highlight-scala"><div class="highlight"><pre><span class="n">akka</span><span class="o">.</span><span class="n">actor</span><span class="o">.</span><span class="n">deployment</span> <span class="o">{</span>
  <span class="o">/</span><span class="n">router</span> <span class="o">{</span>
    <span class="n">router</span> <span class="k">=</span> <span class="n">round</span><span class="o">-</span><span class="n">robin</span>
    <span class="n">nr</span><span class="o">-</span><span class="n">of</span><span class="o">-</span><span class="n">instances</span> <span class="k">=</span> <span class="mi">5</span>
  <span class="o">}</span>
<span class="o">}</span>
</pre></div>
</div>
<div class="highlight-scala"><div class="highlight"><pre><span class="k">val</span> <span class="n">router</span> <span class="k">=</span> <span class="n">system</span><span class="o">.</span><span class="n">actorOf</span><span class="o">(</span><span class="nc">Props</span><span class="o">[</span><span class="kt">ExampleActor</span><span class="o">].</span><span class="n">withRouter</span><span class="o">(</span><span class="nc">FromConfig</span><span class="o">()),</span>
  <span class="s">&quot;router&quot;</span><span class="o">)</span>
</pre></div>
</div>
<p>This is an example of how to programmatically create a router and set the number of routees it should create:</p>
<div class="highlight-scala"><div class="highlight"><pre><span class="k">val</span> <span class="n">router1</span> <span class="k">=</span> <span class="n">system</span><span class="o">.</span><span class="n">actorOf</span><span class="o">(</span><span class="nc">Props</span><span class="o">[</span><span class="kt">ExampleActor1</span><span class="o">].</span><span class="n">withRouter</span><span class="o">(</span>
  <span class="nc">RoundRobinRouter</span><span class="o">(</span><span class="n">nrOfInstances</span> <span class="k">=</span> <span class="mi">5</span><span class="o">)))</span>
</pre></div>
</div>
<p>You can also give the router already created routees as in:</p>
<div class="highlight-scala"><div class="highlight"><pre><span class="k">val</span> <span class="n">actor1</span> <span class="k">=</span> <span class="n">system</span><span class="o">.</span><span class="n">actorOf</span><span class="o">(</span><span class="nc">Props</span><span class="o">[</span><span class="kt">ExampleActor1</span><span class="o">])</span>
<span class="k">val</span> <span class="n">actor2</span> <span class="k">=</span> <span class="n">system</span><span class="o">.</span><span class="n">actorOf</span><span class="o">(</span><span class="nc">Props</span><span class="o">[</span><span class="kt">ExampleActor1</span><span class="o">])</span>
<span class="k">val</span> <span class="n">actor3</span> <span class="k">=</span> <span class="n">system</span><span class="o">.</span><span class="n">actorOf</span><span class="o">(</span><span class="nc">Props</span><span class="o">[</span><span class="kt">ExampleActor1</span><span class="o">])</span>
<span class="k">val</span> <span class="n">routees</span> <span class="k">=</span> <span class="nc">Vector</span><span class="o">[</span><span class="kt">ActorRef</span><span class="o">](</span><span class="n">actor1</span><span class="o">,</span> <span class="n">actor2</span><span class="o">,</span> <span class="n">actor3</span><span class="o">)</span>
<span class="k">val</span> <span class="n">router2</span> <span class="k">=</span> <span class="n">system</span><span class="o">.</span><span class="n">actorOf</span><span class="o">(</span><span class="nc">Props</span><span class="o">[</span><span class="kt">ExampleActor1</span><span class="o">].</span><span class="n">withRouter</span><span class="o">(</span>
  <span class="nc">RoundRobinRouter</span><span class="o">(</span><span class="n">routees</span> <span class="k">=</span> <span class="n">routees</span><span class="o">)))</span>
</pre></div>
</div>
<p>When you create a router programmatically you define the number of routees <em>or</em> you pass already created routees to it.
If you send both parameters to the router <em>only</em> the latter will be used, i.e. <tt class="docutils literal"><span class="pre">nrOfInstances</span></tt> is disregarded.</p>
<p><em>It is also worth pointing out that if you define the ``router`` in the
configuration file then this value will be used instead of any programmatically
sent parameters. The decision whether to create a router at all, on the other
hand, must be taken within the code, i.e. you cannot make something a router by
external configuration alone (see below for details).</em></p>
<p>Once you have the router actor it is just to send messages to it as you would to any actor:</p>
<div class="highlight-scala"><div class="highlight"><pre><span class="n">router</span> <span class="o">!</span> <span class="nc">MyMsg</span>
</pre></div>
</div>
<p>The router will apply its behavior to the message it receives and forward it to the routees.</p>
<div class="section" id="remotely-deploying-routees">
<h3>Remotely Deploying Routees</h3>
<p>In addition to being able to supply looked-up remote actors as routees, you can
make the router deploy its created children on a set of remote hosts; this will
be done in round-robin fashion. In order to do that, wrap the router
configuration in a <tt class="xref py py-class docutils literal"><span class="pre">RemoteRouterConfig</span></tt>, attaching the remote addresses of
the nodes to deploy to. Naturally, this requires your to include the
<tt class="docutils literal"><span class="pre">akka-remote</span></tt> module on your classpath:</p>
<div class="highlight-scala"><div class="highlight"><pre><span class="k">import</span> <span class="nn">akka.actor.</span><span class="o">{</span> <span class="nc">Address</span><span class="o">,</span> <span class="nc">AddressFromURIString</span> <span class="o">}</span>
<span class="k">val</span> <span class="n">addresses</span> <span class="k">=</span> <span class="nc">Seq</span><span class="o">(</span>
  <span class="nc">Address</span><span class="o">(</span><span class="s">&quot;akka&quot;</span><span class="o">,</span> <span class="s">&quot;remotesys&quot;</span><span class="o">,</span> <span class="s">&quot;otherhost&quot;</span><span class="o">,</span> <span class="mi">1234</span><span class="o">),</span>
  <span class="nc">AddressFromURIString</span><span class="o">(</span><span class="s">&quot;akka://othersys@anotherhost:1234&quot;</span><span class="o">))</span>
<span class="k">val</span> <span class="n">routerRemote</span> <span class="k">=</span> <span class="n">system</span><span class="o">.</span><span class="n">actorOf</span><span class="o">(</span><span class="nc">Props</span><span class="o">[</span><span class="kt">ExampleActor1</span><span class="o">].</span><span class="n">withRouter</span><span class="o">(</span>
  <span class="nc">RemoteRouterConfig</span><span class="o">(</span><span class="nc">RoundRobinRouter</span><span class="o">(</span><span class="mi">5</span><span class="o">),</span> <span class="n">addresses</span><span class="o">)))</span>
</pre></div>
</div>
</div>
</div>
<div class="section" id="how-routing-is-designed-within-akka">
<h2>How Routing is Designed within Akka</h2>
<p>Routers behave like single actors, but they should also not hinder scalability.
This apparent contradiction is solved by making routers be represented by a
special <tt class="xref py py-class docutils literal"><span class="pre">RoutedActorRef</span></tt>, which dispatches incoming messages destined
for the routees without actually invoking the router actor’s behavior (and thus
avoiding its mailbox; the single router actor’s task is to manage all aspects
related to the lifecycle of the routees). This means that the code which decides
which route to take is invoked concurrently from all possible senders and hence
must be thread-safe, it cannot live the simple and happy life of code within an
actor.</p>
<p>There is one part in the above paragraph which warrants some more background
explanation: Why does a router need a “head” which is actual parent to all the
routees? The initial design tried to side-step this issue, but location
transparency as well as mandatory parental supervision required a redesign.
Each of the actors which the router spawns must have its unique identity, which
translates into a unique actor path. Since the router has only one given name
in its parent’s context, another level in the name space is needed, which
according to the addressing semantics implies the existence of an actor with
the router’s name. This is not only necessary for the internal messaging
involved in creating, restarting and terminating actors, it is also needed when
the pooled actors need to converse with other actors and receive replies in a
deterministic fashion. Since each actor knows its own external representation
as well as that of its parent, the routees decide where replies should be sent
when reacting to a message:</p>
<div class="highlight-scala"><div class="highlight"><pre><span class="n">sender</span><span class="o">.</span><span class="n">tell</span><span class="o">(</span><span class="s">&quot;reply&quot;</span><span class="o">,</span> <span class="n">context</span><span class="o">.</span><span class="n">parent</span><span class="o">)</span> <span class="c1">// replies will go back to parent</span>
<span class="n">sender</span><span class="o">.!(</span><span class="s">&quot;reply&quot;</span><span class="o">)(</span><span class="n">context</span><span class="o">.</span><span class="n">parent</span><span class="o">)</span> <span class="c1">// alternative syntax (beware of the parens!)</span>
</pre></div>
</div>
<div class="highlight-scala"><div class="highlight"><pre><span class="n">sender</span> <span class="o">!</span> <span class="n">x</span> <span class="c1">// replies will go to this actor</span>
</pre></div>
</div>
<p>It is apparent now why routing needs to be enabled in code rather than being
possible to “bolt on” later: whether or not an actor is routed means a change
to the actor hierarchy, changing the actor paths of all children of the router.
The routees especially do need to know that they are routed to in order to
choose the sender reference for any messages they dispatch as shown above.</p>
</div>
<div class="section" id="routers-vs-supervision">
<h2>Routers vs. Supervision</h2>
<p>As explained in the previous section, routers create new actor instances as
children of the “head” router, who therefor also is their supervisor. The
supervisor strategy of this actor can be configured by means of the
<tt class="xref py py-meth docutils literal"><span class="pre">RouterConfig.supervisorStrategy</span></tt> property, which is supported for all
built-in router types. It defaults to “always escalate”, which leads to the
application of the router’s parent’s supervision directive to all children of
the router uniformly (i.e. not only the one which failed). It should be
mentioned that the router overrides the default behavior of terminating all
children upon restart, which means that a restart—while re-creating them—does
not have an effect on the number of actors in the pool.</p>
<p>Setting the strategy is easily done:</p>
<div class="highlight-scala"><div class="highlight"><pre><span class="k">val</span> <span class="n">escalator</span> <span class="k">=</span> <span class="nc">OneForOneStrategy</span><span class="o">()</span> <span class="o">{</span>
  <span class="c1">// custom strategy ...</span>
<span class="o">}</span>
<span class="k">val</span> <span class="n">router</span> <span class="k">=</span> <span class="n">system</span><span class="o">.</span><span class="n">actorOf</span><span class="o">(</span><span class="nc">Props</span><span class="o">.</span><span class="n">empty</span><span class="o">.</span><span class="n">withRouter</span><span class="o">(</span>
  <span class="nc">RoundRobinRouter</span><span class="o">(</span><span class="mi">1</span><span class="o">,</span> <span class="n">supervisorStrategy</span> <span class="k">=</span> <span class="n">escalator</span><span class="o">)))</span>
</pre></div>
</div>
<p>Another potentially useful approach is to give the router the same strategy as
its parent, which effectively treats all actors in the pool as if they were
direct children of their grand-parent instead.</p>
</div>
<div class="section" id="router-usage">
<h2>Router usage</h2>
<p>In this section we will describe how to use the different router types.
First we need to create some actors that will be used in the examples:</p>
<div class="highlight-scala"><div class="highlight"><pre><span class="k">class</span> <span class="nc">PrintlnActor</span> <span class="k">extends</span> <span class="nc">Actor</span> <span class="o">{</span>
  <span class="k">def</span> <span class="n">receive</span> <span class="k">=</span> <span class="o">{</span>
    <span class="k">case</span> <span class="n">msg</span> <span class="k">⇒</span>
      <span class="n">println</span><span class="o">(</span><span class="s">&quot;Received message &#39;%s&#39; in actor %s&quot;</span><span class="o">.</span><span class="n">format</span><span class="o">(</span><span class="n">msg</span><span class="o">,</span> <span class="n">self</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">name</span><span class="o">))</span>
  <span class="o">}</span>
<span class="o">}</span>
</pre></div>
</div>
<p>and</p>
<div class="highlight-scala"><div class="highlight"><pre><span class="k">class</span> <span class="nc">FibonacciActor</span> <span class="k">extends</span> <span class="nc">Actor</span> <span class="o">{</span>
  <span class="k">def</span> <span class="n">receive</span> <span class="k">=</span> <span class="o">{</span>
    <span class="k">case</span> <span class="nc">FibonacciNumber</span><span class="o">(</span><span class="n">nbr</span><span class="o">)</span> <span class="k">⇒</span> <span class="n">sender</span> <span class="n">tell</span> <span class="n">fibonacci</span><span class="o">(</span><span class="n">nbr</span><span class="o">)</span>
  <span class="o">}</span>

  <span class="k">private</span> <span class="k">def</span> <span class="n">fibonacci</span><span class="o">(</span><span class="n">n</span><span class="k">:</span> <span class="kt">Int</span><span class="o">)</span><span class="k">:</span> <span class="kt">Int</span> <span class="o">=</span> <span class="o">{</span>
    <span class="nd">@tailrec</span>
    <span class="k">def</span> <span class="n">fib</span><span class="o">(</span><span class="n">n</span><span class="k">:</span> <span class="kt">Int</span><span class="o">,</span> <span class="n">b</span><span class="k">:</span> <span class="kt">Int</span><span class="o">,</span> <span class="n">a</span><span class="k">:</span> <span class="kt">Int</span><span class="o">)</span><span class="k">:</span> <span class="kt">Int</span> <span class="o">=</span> <span class="n">n</span> <span class="k">match</span> <span class="o">{</span>
      <span class="k">case</span> <span class="mi">0</span> <span class="k">⇒</span> <span class="n">a</span>
      <span class="k">case</span> <span class="k">_</span> <span class="k">⇒</span> <span class="n">fib</span><span class="o">(</span><span class="n">n</span> <span class="o">-</span> <span class="mi">1</span><span class="o">,</span> <span class="n">a</span> <span class="o">+</span> <span class="n">b</span><span class="o">,</span> <span class="n">b</span><span class="o">)</span>
    <span class="o">}</span>

    <span class="n">fib</span><span class="o">(</span><span class="n">n</span><span class="o">,</span> <span class="mi">1</span><span class="o">,</span> <span class="mi">0</span><span class="o">)</span>
  <span class="o">}</span>
<span class="o">}</span>
</pre></div>
</div>
<div class="section" id="roundrobinrouter">
<h3>RoundRobinRouter</h3>
<p>Routes in a <a class="reference external" href="http://en.wikipedia.org/wiki/Round-robin">round-robin</a> fashion to its routees.
Code example:</p>
<div class="highlight-scala"><div class="highlight"><pre><span class="k">val</span> <span class="n">roundRobinRouter</span> <span class="k">=</span>
  <span class="n">context</span><span class="o">.</span><span class="n">actorOf</span><span class="o">(</span><span class="nc">Props</span><span class="o">[</span><span class="kt">PrintlnActor</span><span class="o">].</span><span class="n">withRouter</span><span class="o">(</span><span class="nc">RoundRobinRouter</span><span class="o">(</span><span class="mi">5</span><span class="o">)),</span> <span class="s">&quot;router&quot;</span><span class="o">)</span>
<span class="mi">1</span> <span class="n">to</span> <span class="mi">10</span> <span class="n">foreach</span> <span class="o">{</span>
  <span class="n">i</span> <span class="k">⇒</span> <span class="n">roundRobinRouter</span> <span class="o">!</span> <span class="n">i</span>
<span class="o">}</span>
</pre></div>
</div>
<p>When run you should see a similar output to this:</p>
<div class="highlight-scala"><pre>Received message '1' in actor $b
Received message '2' in actor $c
Received message '3' in actor $d
Received message '6' in actor $b
Received message '4' in actor $e
Received message '8' in actor $d
Received message '5' in actor $f
Received message '9' in actor $e
Received message '10' in actor $f
Received message '7' in actor $c</pre>
</div>
<p>If you look closely to the output you can see that each of the routees received two messages which
is exactly what you would expect from a round-robin router to happen.
(The name of an actor is automatically created in the format <tt class="docutils literal"><span class="pre">$letter</span></tt> unless you specify it -
hence the names printed above.)</p>
</div>
<div class="section" id="randomrouter">
<h3>RandomRouter</h3>
<p>As the name implies this router type selects one of its routees randomly and forwards
the message it receives to this routee.
This procedure will happen each time it receives a message.
Code example:</p>
<div class="highlight-scala"><div class="highlight"><pre><span class="k">val</span> <span class="n">randomRouter</span> <span class="k">=</span>
  <span class="n">context</span><span class="o">.</span><span class="n">actorOf</span><span class="o">(</span><span class="nc">Props</span><span class="o">[</span><span class="kt">PrintlnActor</span><span class="o">].</span><span class="n">withRouter</span><span class="o">(</span><span class="nc">RandomRouter</span><span class="o">(</span><span class="mi">5</span><span class="o">)),</span> <span class="s">&quot;router&quot;</span><span class="o">)</span>
<span class="mi">1</span> <span class="n">to</span> <span class="mi">10</span> <span class="n">foreach</span> <span class="o">{</span>
  <span class="n">i</span> <span class="k">⇒</span> <span class="n">randomRouter</span> <span class="o">!</span> <span class="n">i</span>
<span class="o">}</span>
</pre></div>
</div>
<p>When run you should see a similar output to this:</p>
<div class="highlight-scala"><pre>Received message '1' in actor $e
Received message '2' in actor $c
Received message '4' in actor $b
Received message '5' in actor $d
Received message '3' in actor $e
Received message '6' in actor $c
Received message '7' in actor $d
Received message '8' in actor $e
Received message '9' in actor $d
Received message '10' in actor $d</pre>
</div>
<p>The result from running the random router should be different, or at least random, every time you run it.
Try to run it a couple of times to verify its behavior if you don&#8217;t trust us.</p>
</div>
<div class="section" id="smallestmailboxrouter">
<h3>SmallestMailboxRouter</h3>
<p>A Router that tries to send to the non-suspended routee with fewest messages in mailbox.
The selection is done in this order:</p>
<blockquote>
<div><ul class="simple">
<li>pick any idle routee (not processing message) with empty mailbox</li>
<li>pick any routee with empty mailbox</li>
<li>pick routee with fewest pending messages in mailbox</li>
<li>pick any remote routee, remote actors are consider lowest priority,
since their mailbox size is unknown</li>
</ul>
</div></blockquote>
<p>Code example:</p>
<div class="highlight-scala"><div class="highlight"><pre><span class="k">val</span> <span class="n">smallestMailboxRouter</span> <span class="k">=</span>
  <span class="n">context</span><span class="o">.</span><span class="n">actorOf</span><span class="o">(</span><span class="nc">Props</span><span class="o">[</span><span class="kt">PrintlnActor</span><span class="o">].</span><span class="n">withRouter</span><span class="o">(</span><span class="nc">SmallestMailboxRouter</span><span class="o">(</span><span class="mi">5</span><span class="o">)),</span> <span class="s">&quot;router&quot;</span><span class="o">)</span>
<span class="mi">1</span> <span class="n">to</span> <span class="mi">10</span> <span class="n">foreach</span> <span class="o">{</span>
  <span class="n">i</span> <span class="k">⇒</span> <span class="n">smallestMailboxRouter</span> <span class="o">!</span> <span class="n">i</span>
<span class="o">}</span>
</pre></div>
</div>
</div>
<div class="section" id="broadcastrouter">
<h3>BroadcastRouter</h3>
<p>A broadcast router forwards the message it receives to <em>all</em> its routees.
Code example:</p>
<div class="highlight-scala"><div class="highlight"><pre><span class="k">val</span> <span class="n">broadcastRouter</span> <span class="k">=</span>
  <span class="n">context</span><span class="o">.</span><span class="n">actorOf</span><span class="o">(</span><span class="nc">Props</span><span class="o">[</span><span class="kt">PrintlnActor</span><span class="o">].</span><span class="n">withRouter</span><span class="o">(</span><span class="nc">BroadcastRouter</span><span class="o">(</span><span class="mi">5</span><span class="o">)),</span> <span class="s">&quot;router&quot;</span><span class="o">)</span>
<span class="n">broadcastRouter</span> <span class="o">!</span> <span class="s">&quot;this is a broadcast message&quot;</span>
</pre></div>
</div>
<p>When run you should see a similar output to this:</p>
<div class="highlight-scala"><pre>Received message 'this is a broadcast message' in actor $f
Received message 'this is a broadcast message' in actor $d
Received message 'this is a broadcast message' in actor $e
Received message 'this is a broadcast message' in actor $c
Received message 'this is a broadcast message' in actor $b</pre>
</div>
<p>As you can see here above each of the routees, five in total, received the broadcast message.</p>
</div>
<div class="section" id="scattergatherfirstcompletedrouter">
<h3>ScatterGatherFirstCompletedRouter</h3>
<p>The ScatterGatherFirstCompletedRouter will send the message on to all its routees as a future.
It then waits for first result it gets back. This result will be sent back to original sender.
Code example:</p>
<div class="highlight-scala"><div class="highlight"><pre><span class="k">val</span> <span class="n">scatterGatherFirstCompletedRouter</span> <span class="k">=</span> <span class="n">context</span><span class="o">.</span><span class="n">actorOf</span><span class="o">(</span>
  <span class="nc">Props</span><span class="o">[</span><span class="kt">FibonacciActor</span><span class="o">].</span><span class="n">withRouter</span><span class="o">(</span><span class="nc">ScatterGatherFirstCompletedRouter</span><span class="o">(</span>
    <span class="n">nrOfInstances</span> <span class="k">=</span> <span class="mi">5</span><span class="o">,</span> <span class="n">within</span> <span class="k">=</span> <span class="mi">2</span> <span class="n">seconds</span><span class="o">)),</span> <span class="s">&quot;router&quot;</span><span class="o">)</span>
<span class="k">implicit</span> <span class="k">val</span> <span class="n">timeout</span> <span class="k">=</span> <span class="nc">Timeout</span><span class="o">(</span><span class="mi">5</span> <span class="n">seconds</span><span class="o">)</span>
<span class="k">val</span> <span class="n">futureResult</span> <span class="k">=</span> <span class="n">scatterGatherFirstCompletedRouter</span> <span class="o">?</span> <span class="nc">FibonacciNumber</span><span class="o">(</span><span class="mi">10</span><span class="o">)</span>
<span class="k">val</span> <span class="n">result</span> <span class="k">=</span> <span class="nc">Await</span><span class="o">.</span><span class="n">result</span><span class="o">(</span><span class="n">futureResult</span><span class="o">,</span> <span class="n">timeout</span><span class="o">.</span><span class="n">duration</span><span class="o">)</span>
</pre></div>
</div>
<p>When run you should see this:</p>
<div class="highlight-scala"><div class="highlight"><pre><span class="nc">The</span> <span class="n">result</span> <span class="n">of</span> <span class="n">calculating</span> <span class="nc">Fibonacci</span> <span class="k">for</span> <span class="mi">10</span> <span class="n">is</span> <span class="mi">55</span>
</pre></div>
</div>
<p>From the output above you can&#8217;t really see that all the routees performed the calculation, but they did!
The result you see is from the first routee that returned its calculation to the router.</p>
</div>
</div>
<div class="section" id="broadcast-messages">
<h2>Broadcast Messages</h2>
<p>There is a special type of message that will be sent to all routees regardless of the router.
This message is called <tt class="docutils literal"><span class="pre">Broadcast</span></tt> and is used in the following manner:</p>
<div class="highlight-scala"><div class="highlight"><pre><span class="n">router</span> <span class="o">!</span> <span class="nc">Broadcast</span><span class="o">(</span><span class="s">&quot;Watch out for Davy Jones&#39; locker&quot;</span><span class="o">)</span>
</pre></div>
</div>
<p>Only the actual message is forwarded to the routees, i.e. &#8220;Watch out for Davy Jones&#8217; locker&#8221; in the example above.
It is up to the routee implementation whether to handle the broadcast message or not.</p>
</div>
<div class="section" id="dynamically-resizable-routers">
<h2>Dynamically Resizable Routers</h2>
<p>All routers can be used with a fixed number of routees or with a resize strategy to adjust the number
of routees dynamically.</p>
<p>This is an example of how to create a resizable router that is defined in configuration:</p>
<div class="highlight-scala"><div class="highlight"><pre><span class="n">akka</span><span class="o">.</span><span class="n">actor</span><span class="o">.</span><span class="n">deployment</span> <span class="o">{</span>
  <span class="o">/</span><span class="n">router2</span> <span class="o">{</span>
    <span class="n">router</span> <span class="k">=</span> <span class="n">round</span><span class="o">-</span><span class="n">robin</span>
    <span class="n">resizer</span> <span class="o">{</span>
      <span class="n">lower</span><span class="o">-</span><span class="n">bound</span> <span class="k">=</span> <span class="mi">2</span>
      <span class="n">upper</span><span class="o">-</span><span class="n">bound</span> <span class="k">=</span> <span class="mi">15</span>
    <span class="o">}</span>
  <span class="o">}</span>
<span class="o">}</span>
</pre></div>
</div>
<div class="highlight-scala"><div class="highlight"><pre><span class="k">val</span> <span class="n">router2</span> <span class="k">=</span> <span class="n">system</span><span class="o">.</span><span class="n">actorOf</span><span class="o">(</span><span class="nc">Props</span><span class="o">[</span><span class="kt">ExampleActor</span><span class="o">].</span><span class="n">withRouter</span><span class="o">(</span><span class="nc">FromConfig</span><span class="o">()),</span>
  <span class="s">&quot;router2&quot;</span><span class="o">)</span>
</pre></div>
</div>
<p>Several more configuration options are available and described in <tt class="docutils literal"><span class="pre">akka.actor.deployment.default.resizer</span></tt>
section of the reference <a class="reference internal" href="../general/configuration.html#configuration"><em>Configuration</em></a>.</p>
<p>This is an example of how to programmatically create a resizable router:</p>
<div class="highlight-scala"><div class="highlight"><pre><span class="k">val</span> <span class="n">resizer</span> <span class="k">=</span> <span class="nc">DefaultResizer</span><span class="o">(</span><span class="n">lowerBound</span> <span class="k">=</span> <span class="mi">2</span><span class="o">,</span> <span class="n">upperBound</span> <span class="k">=</span> <span class="mi">15</span><span class="o">)</span>
<span class="k">val</span> <span class="n">router3</span> <span class="k">=</span> <span class="n">system</span><span class="o">.</span><span class="n">actorOf</span><span class="o">(</span><span class="nc">Props</span><span class="o">[</span><span class="kt">ExampleActor1</span><span class="o">].</span><span class="n">withRouter</span><span class="o">(</span>
  <span class="nc">RoundRobinRouter</span><span class="o">(</span><span class="n">resizer</span> <span class="k">=</span> <span class="nc">Some</span><span class="o">(</span><span class="n">resizer</span><span class="o">))))</span>
</pre></div>
</div>
<p><em>It is also worth pointing out that if you define the ``router`` in the configuration file then this value
will be used instead of any programmatically sent parameters.</em></p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">Resizing is triggered by sending messages to the actor pool, but it is not
completed synchronously; instead a message is sent to the “head”
<tt class="xref py py-class docutils literal"><span class="pre">Router</span></tt> to perform the size change. Thus you cannot rely on resizing
to instantaneously create new workers when all others are busy, because the
message just sent will be queued to the mailbox of a busy actor. To remedy
this, configure the pool to use a balancing dispatcher, see <a class="reference internal" href="#configuring-dispatchers">Configuring
Dispatchers</a> for more information.</p>
</div>
</div>
<div class="section" id="custom-router">
<h2>Custom Router</h2>
<p>You can also create your own router should you not find any of the ones provided by Akka sufficient for your needs.
In order to roll your own router you have to fulfill certain criteria which are explained in this section.</p>
<p>The router created in this example is a simple vote counter. It will route the votes to specific vote counter actors.
In this case we only have two parties the Republicans and the Democrats. We would like a router that forwards all
democrat related messages to the Democrat actor and all republican related messages to the Republican actor.</p>
<p>We begin with defining the class:</p>
<div class="highlight-scala"><div class="highlight"><pre><span class="k">case</span> <span class="k">class</span> <span class="nc">VoteCountRouter</span><span class="o">()</span> <span class="k">extends</span> <span class="nc">RouterConfig</span> <span class="o">{</span>

  <span class="k">def</span> <span class="n">routerDispatcher</span><span class="k">:</span> <span class="kt">String</span> <span class="o">=</span> <span class="nc">Dispatchers</span><span class="o">.</span><span class="nc">DefaultDispatcherId</span>
  <span class="k">def</span> <span class="n">supervisorStrategy</span><span class="k">:</span> <span class="kt">SupervisorStrategy</span> <span class="o">=</span> <span class="nc">SupervisorStrategy</span><span class="o">.</span><span class="n">defaultStrategy</span>

  <span class="c1">// crRoute ...</span>

<span class="o">}</span>
</pre></div>
</div>
<p>The next step is to implement the <tt class="docutils literal"><span class="pre">createRoute</span></tt> method in the class just defined:</p>
<div class="highlight-scala"><div class="highlight"><pre><span class="k">def</span> <span class="n">createRoute</span><span class="o">(</span><span class="n">routeeProps</span><span class="k">:</span> <span class="kt">Props</span><span class="o">,</span> <span class="n">routeeProvider</span><span class="k">:</span> <span class="kt">RouteeProvider</span><span class="o">)</span><span class="k">:</span> <span class="kt">Route</span> <span class="o">=</span> <span class="o">{</span>
  <span class="k">val</span> <span class="n">democratActor</span> <span class="k">=</span> <span class="n">routeeProvider</span><span class="o">.</span><span class="n">context</span><span class="o">.</span><span class="n">actorOf</span><span class="o">(</span><span class="nc">Props</span><span class="o">(</span><span class="k">new</span> <span class="nc">DemocratActor</span><span class="o">()),</span> <span class="s">&quot;d&quot;</span><span class="o">)</span>
  <span class="k">val</span> <span class="n">republicanActor</span> <span class="k">=</span> <span class="n">routeeProvider</span><span class="o">.</span><span class="n">context</span><span class="o">.</span><span class="n">actorOf</span><span class="o">(</span><span class="nc">Props</span><span class="o">(</span><span class="k">new</span> <span class="nc">RepublicanActor</span><span class="o">()),</span> <span class="s">&quot;r&quot;</span><span class="o">)</span>
  <span class="k">val</span> <span class="n">routees</span> <span class="k">=</span> <span class="nc">Vector</span><span class="o">[</span><span class="kt">ActorRef</span><span class="o">](</span><span class="n">democratActor</span><span class="o">,</span> <span class="n">republicanActor</span><span class="o">)</span>

  <span class="n">routeeProvider</span><span class="o">.</span><span class="n">registerRoutees</span><span class="o">(</span><span class="n">routees</span><span class="o">)</span>

  <span class="o">{</span>
    <span class="k">case</span> <span class="o">(</span><span class="n">sender</span><span class="o">,</span> <span class="n">message</span><span class="o">)</span> <span class="k">⇒</span>
      <span class="n">message</span> <span class="k">match</span> <span class="o">{</span>
        <span class="k">case</span> <span class="nc">DemocratVote</span> <span class="o">|</span> <span class="nc">DemocratCountResult</span> <span class="k">⇒</span>
          <span class="nc">List</span><span class="o">(</span><span class="nc">Destination</span><span class="o">(</span><span class="n">sender</span><span class="o">,</span> <span class="n">democratActor</span><span class="o">))</span>
        <span class="k">case</span> <span class="nc">RepublicanVote</span> <span class="o">|</span> <span class="nc">RepublicanCountResult</span> <span class="k">⇒</span>
          <span class="nc">List</span><span class="o">(</span><span class="nc">Destination</span><span class="o">(</span><span class="n">sender</span><span class="o">,</span> <span class="n">republicanActor</span><span class="o">))</span>
      <span class="o">}</span>
  <span class="o">}</span>
<span class="o">}</span>
</pre></div>
</div>
<p>As you can see above we start off by creating the routees and put them in a collection.</p>
<p>Make sure that you don&#8217;t miss to implement the line below as it is <em>really</em> important.
It registers the routees internally and failing to call this method will
cause a <tt class="docutils literal"><span class="pre">ActorInitializationException</span></tt> to be thrown when the router is used.
Therefore always make sure to do the following in your custom router:</p>
<div class="highlight-scala"><div class="highlight"><pre><span class="n">routeeProvider</span><span class="o">.</span><span class="n">registerRoutees</span><span class="o">(</span><span class="n">routees</span><span class="o">)</span>
</pre></div>
</div>
<p>The routing logic is where your magic sauce is applied. In our example it inspects the message types
and forwards to the correct routee based on this:</p>
<div class="highlight-scala"><div class="highlight"><pre><span class="o">{</span>
  <span class="k">case</span> <span class="o">(</span><span class="n">sender</span><span class="o">,</span> <span class="n">message</span><span class="o">)</span> <span class="k">⇒</span>
    <span class="n">message</span> <span class="k">match</span> <span class="o">{</span>
      <span class="k">case</span> <span class="nc">DemocratVote</span> <span class="o">|</span> <span class="nc">DemocratCountResult</span> <span class="k">⇒</span>
        <span class="nc">List</span><span class="o">(</span><span class="nc">Destination</span><span class="o">(</span><span class="n">sender</span><span class="o">,</span> <span class="n">democratActor</span><span class="o">))</span>
      <span class="k">case</span> <span class="nc">RepublicanVote</span> <span class="o">|</span> <span class="nc">RepublicanCountResult</span> <span class="k">⇒</span>
        <span class="nc">List</span><span class="o">(</span><span class="nc">Destination</span><span class="o">(</span><span class="n">sender</span><span class="o">,</span> <span class="n">republicanActor</span><span class="o">))</span>
    <span class="o">}</span>
<span class="o">}</span>
</pre></div>
</div>
<p>As you can see above what&#8217;s returned in the partial function is a <tt class="docutils literal"><span class="pre">List</span></tt> of <tt class="docutils literal"><span class="pre">Destination(sender,</span> <span class="pre">routee)</span></tt>.
The sender is what &#8220;parent&#8221; the routee should see - changing this could be useful if you for example want
another actor than the original sender to intermediate the result of the routee (if there is a result).
For more information about how to alter the original sender we refer to the source code of
<a class="reference external" href="https://github.com/akka/akka/blob/master/akka-actor/src/main/scala/akka/routing/Routing.scala#L375">ScatterGatherFirstCompletedRouter</a></p>
<p>All in all the custom router looks like this:</p>
<div class="highlight-scala"><div class="highlight"><pre><span class="k">case</span> <span class="k">object</span> <span class="nc">DemocratVote</span>
<span class="k">case</span> <span class="k">object</span> <span class="nc">DemocratCountResult</span>
<span class="k">case</span> <span class="k">object</span> <span class="nc">RepublicanVote</span>
<span class="k">case</span> <span class="k">object</span> <span class="nc">RepublicanCountResult</span>

<span class="k">class</span> <span class="nc">DemocratActor</span> <span class="k">extends</span> <span class="nc">Actor</span> <span class="o">{</span>
  <span class="k">var</span> <span class="n">counter</span> <span class="k">=</span> <span class="mi">0</span>

  <span class="k">def</span> <span class="n">receive</span> <span class="k">=</span> <span class="o">{</span>
    <span class="k">case</span> <span class="nc">DemocratVote</span>        <span class="k">⇒</span> <span class="n">counter</span> <span class="o">+=</span> <span class="mi">1</span>
    <span class="k">case</span> <span class="nc">DemocratCountResult</span> <span class="k">⇒</span> <span class="n">sender</span> <span class="o">!</span> <span class="n">counter</span>
  <span class="o">}</span>
<span class="o">}</span>

<span class="k">class</span> <span class="nc">RepublicanActor</span> <span class="k">extends</span> <span class="nc">Actor</span> <span class="o">{</span>
  <span class="k">var</span> <span class="n">counter</span> <span class="k">=</span> <span class="mi">0</span>

  <span class="k">def</span> <span class="n">receive</span> <span class="k">=</span> <span class="o">{</span>
    <span class="k">case</span> <span class="nc">RepublicanVote</span>        <span class="k">⇒</span> <span class="n">counter</span> <span class="o">+=</span> <span class="mi">1</span>
    <span class="k">case</span> <span class="nc">RepublicanCountResult</span> <span class="k">⇒</span> <span class="n">sender</span> <span class="o">!</span> <span class="n">counter</span>
  <span class="o">}</span>
<span class="o">}</span>

<span class="k">case</span> <span class="k">class</span> <span class="nc">VoteCountRouter</span><span class="o">()</span> <span class="k">extends</span> <span class="nc">RouterConfig</span> <span class="o">{</span>

  <span class="k">def</span> <span class="n">routerDispatcher</span><span class="k">:</span> <span class="kt">String</span> <span class="o">=</span> <span class="nc">Dispatchers</span><span class="o">.</span><span class="nc">DefaultDispatcherId</span>
  <span class="k">def</span> <span class="n">supervisorStrategy</span><span class="k">:</span> <span class="kt">SupervisorStrategy</span> <span class="o">=</span> <span class="nc">SupervisorStrategy</span><span class="o">.</span><span class="n">defaultStrategy</span>

  <span class="k">def</span> <span class="n">createRoute</span><span class="o">(</span><span class="n">routeeProps</span><span class="k">:</span> <span class="kt">Props</span><span class="o">,</span> <span class="n">routeeProvider</span><span class="k">:</span> <span class="kt">RouteeProvider</span><span class="o">)</span><span class="k">:</span> <span class="kt">Route</span> <span class="o">=</span> <span class="o">{</span>
    <span class="k">val</span> <span class="n">democratActor</span> <span class="k">=</span> <span class="n">routeeProvider</span><span class="o">.</span><span class="n">context</span><span class="o">.</span><span class="n">actorOf</span><span class="o">(</span><span class="nc">Props</span><span class="o">(</span><span class="k">new</span> <span class="nc">DemocratActor</span><span class="o">()),</span> <span class="s">&quot;d&quot;</span><span class="o">)</span>
    <span class="k">val</span> <span class="n">republicanActor</span> <span class="k">=</span> <span class="n">routeeProvider</span><span class="o">.</span><span class="n">context</span><span class="o">.</span><span class="n">actorOf</span><span class="o">(</span><span class="nc">Props</span><span class="o">(</span><span class="k">new</span> <span class="nc">RepublicanActor</span><span class="o">()),</span> <span class="s">&quot;r&quot;</span><span class="o">)</span>
    <span class="k">val</span> <span class="n">routees</span> <span class="k">=</span> <span class="nc">Vector</span><span class="o">[</span><span class="kt">ActorRef</span><span class="o">](</span><span class="n">democratActor</span><span class="o">,</span> <span class="n">republicanActor</span><span class="o">)</span>

    <span class="n">routeeProvider</span><span class="o">.</span><span class="n">registerRoutees</span><span class="o">(</span><span class="n">routees</span><span class="o">)</span>

    <span class="o">{</span>
      <span class="k">case</span> <span class="o">(</span><span class="n">sender</span><span class="o">,</span> <span class="n">message</span><span class="o">)</span> <span class="k">⇒</span>
        <span class="n">message</span> <span class="k">match</span> <span class="o">{</span>
          <span class="k">case</span> <span class="nc">DemocratVote</span> <span class="o">|</span> <span class="nc">DemocratCountResult</span> <span class="k">⇒</span>
            <span class="nc">List</span><span class="o">(</span><span class="nc">Destination</span><span class="o">(</span><span class="n">sender</span><span class="o">,</span> <span class="n">democratActor</span><span class="o">))</span>
          <span class="k">case</span> <span class="nc">RepublicanVote</span> <span class="o">|</span> <span class="nc">RepublicanCountResult</span> <span class="k">⇒</span>
            <span class="nc">List</span><span class="o">(</span><span class="nc">Destination</span><span class="o">(</span><span class="n">sender</span><span class="o">,</span> <span class="n">republicanActor</span><span class="o">))</span>
        <span class="o">}</span>
    <span class="o">}</span>
  <span class="o">}</span>

<span class="o">}</span>
</pre></div>
</div>
<p>If you are interested in how to use the VoteCountRouter you can have a look at the test class
<a class="reference external" href="https://github.com/akka/akka/blob/master/akka-actor-tests/src/test/scala/akka/routing/RoutingSpec.scala">RoutingSpec</a></p>
<div class="section" id="configured-custom-router">
<h3>Configured Custom Router</h3>
<p>It is possible to define configuration properties for custom routers. In the <tt class="docutils literal"><span class="pre">router</span></tt> property of the deployment
configuration you define the fully qualified class name of the router class. The router class must extend
<tt class="docutils literal"><span class="pre">akka.routing.RouterConfig</span></tt> and and have constructor with <tt class="docutils literal"><span class="pre">com.typesafe.config.Config</span></tt> parameter.
The deployment section of the configuration is passed to the constructor.</p>
</div>
<div class="section" id="custom-resizer">
<h3>Custom Resizer</h3>
<p>A router with dynamically resizable number of routees is implemented by providing a <tt class="docutils literal"><span class="pre">akka.routing.Resizer</span></tt>
in <tt class="docutils literal"><span class="pre">resizer</span></tt> method of the <tt class="docutils literal"><span class="pre">RouterConfig</span></tt>. See <tt class="docutils literal"><span class="pre">akka.routing.DefaultResizer</span></tt> for inspiration
of how to write your own resize strategy.</p>
</div>
</div>
<div class="section" id="configuring-dispatchers">
<h2>Configuring Dispatchers</h2>
<p>The dispatcher for created children of the router will be taken from
<tt class="xref py py-class docutils literal"><span class="pre">Props</span></tt> as described in <a class="reference internal" href="dispatchers.html#dispatchers-scala"><em>Dispatchers (Scala)</em></a>. For a dynamic pool it
makes sense to configure the <tt class="xref py py-class docutils literal"><span class="pre">BalancingDispatcher</span></tt> if the precise
routing is not so important (i.e. no consistent hashing or round-robin is
required); this enables newly created routees to pick up work immediately by
stealing it from their siblings.</p>
<p>The “head” router, of course, cannot run on the same balancing dispatcher,
because it does not process the same messages, hence this special actor does
not use the dispatcher configured in <tt class="xref py py-class docutils literal"><span class="pre">Props</span></tt>, but takes the
<tt class="docutils literal"><span class="pre">routerDispatcher</span></tt> from the <tt class="xref py py-class docutils literal"><span class="pre">RouterConfig</span></tt> instead, which defaults to
the actor system’s default dispatcher. All standard routers allow setting this
property in their constructor or factory method, custom routers have to
implement the method in a suitable way.</p>
<div class="highlight-scala"><div class="highlight"><pre><span class="k">val</span> <span class="n">router</span> <span class="k">=</span> <span class="n">system</span><span class="o">.</span><span class="n">actorOf</span><span class="o">(</span><span class="nc">Props</span><span class="o">[</span><span class="kt">MyActor</span><span class="o">]</span>
  <span class="o">.</span><span class="n">withRouter</span><span class="o">(</span><span class="nc">RoundRobinRouter</span><span class="o">(</span><span class="mi">5</span><span class="o">,</span> <span class="n">routerDispatcher</span> <span class="k">=</span> <span class="s">&quot;router&quot;</span><span class="o">))</span> <span class="c1">// “head” will run on &quot;router&quot; dispatcher</span>
  <span class="o">.</span><span class="n">withDispatcher</span><span class="o">(</span><span class="s">&quot;workers&quot;</span><span class="o">))</span> <span class="c1">// MyActor workers will run on &quot;workers&quot; dispatcher</span>
</pre></div>
</div>
</div>
</div>


          </div>
          <div class="span3"><p class="contents-title">Contents</p>
              <div id="scroller-anchor">
                <div id="scroller">
                  <div id="toc"></div>
                </div>
              </div></div>
        </div>
      </div>
    </div>
  </div>
  <div class="footer">
  <div class="container">
    <ul>
      <li><h5>Akka</h5></li>
      <li><a href="http://akka.io/docs">Documentation</a></li>
      <li><a href="http://akka.io/downloads">Downloads</a></li>
    </ul>
    <ul>
      <li><h5>Contribute</h5></li>
      <li><a href="http://github.com/akka/akka">Source Code</a></li>
      <li><a href="http://groups.google.com/group/akka-user">Mailing List</a></li>      
      <li><a href="http://www.assembla.com/spaces/akka/tickets">Report a Bug</a></li>      
    </ul>
    <ul>
      <li><h5>Company</h5></li>
      <li><a href="http://typesafe.com/products/typesafe-subscription">Commercial Support</a></li>
      <li><a href="http://akka.io/team">Team</a></li>
      <li><a href="mailto:info@typesafe.com">Contact</a></li>
    </ul>
    <ul>
      <li><img src="../_static/watermark.png" align="center"/></li>
    </ul>
  </div>
  <div class="container copyright">
    <p style="float: left;">
      © 2012 <a href="http://typesafe.com/">Typesafe Inc.</a> <span class="license">Akka is Open Source and available under the Apache 2 License.</span>
    </p>
    <p style="float: right; font-size: 12px;">
      Last updated: Apr 13, 2012
    </p>          
  </div>
</div>
<script type="text/javascript">
  $('#toc').toc();
</script>
  

  </body>
</html>